package com.collect.collect.api.service.impl;

import com.collect.collect.api.dao.DataReceivingMapper;
import com.collect.collect.api.service.IMasterService;
import com.collect.collect.config.annotation.DataSource;
import com.collect.collect.config.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
import java.util.Set;

@DataSource(value = DataSourceType.MASTER)
@Service
public class MasterServiceImpl implements IMasterService {

    @Autowired
    private DataReceivingMapper dataReceivingMapper;

    /**
     * 获取表字段Set集合
     * @param tableName
     * @return
     */
    @Override
    public Set<String> selectColumnList(String tableName) {
        return dataReceivingMapper.selectColumnList(tableName);
    }

    /**
     * 查询表达梦字段名
     * @param owner 模式名
     * @param tableName 表名
     * @return
     */
    @Override
    public Set<String> selectDmColumnList(String owner, String tableName) {
        return dataReceivingMapper.selectDmColumnList(owner,tableName);
    }

    /**
     * 动态表批量插入
     * @param paramMap
     * @param tableName
     * @return
     */
    @Transactional(readOnly = false)
    @Override
    public int insertMapDataList(List<Map<String, Object>> paramMap, String tableName) {
        return dataReceivingMapper.insertMapDataList(paramMap,tableName);
    }
}
